﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

namespace Lesson02
{
    public class LabeledTextBox : TextBox
    {
        public string PromptText
        {
            get
            {
                string s = (string)this.ViewState["PromptText"];
                return s == null ? string.Empty : s;
            }
            set
            {
                this.ViewState["PromptText"] = value;
            }
        }

        public int PromptWidth { get; set; }

        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            writer.Write(@"<span style=""display:inline-block;width:{0}px"">{1}&nbsp;</span>", this.PromptWidth, this.PromptText);
            base.Render(writer);
        }
    }
}